package cn.liujianbo.example.dockerdemo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author 刘建波
 * @date 2021-10-18 23:08
 */
@RestController
@RequestMapping("/")
public class HelloDockerController {
    private static AtomicInteger requestCount = new AtomicInteger();
    @Autowired
    private RedisTemplate redisTemplate;

    @GetMapping("")
    public String helloDocker(){
        return "欢迎访问，第 " + redisTemplate.opsForValue().increment("count") + " 次浏览；本服务处理的的第：" + requestCount.getAndIncrement()+"个请求！";
    }
}
